//
//  PersonalInformationView.m
//  DJS
//
//  Created by 浪尖渝力 on 2018/2/7.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "PersonalInformationView.h"
#import "selectAddView.h"
#import "selectZC.h"
#import "jianJieViewController.h"

@implementation PersonalInformationView

-(void)creatView{
    self.backgroundColor=_LightGrey;
    
    _scrollView=[UIScrollView new];
    [self addSubview:_scrollView];
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    _scrollView.scrollsToTop =NO;
    
    _scrollView.showsVerticalScrollIndicator = FALSE;
    _scrollView.showsHorizontalScrollIndicator = FALSE;
    _scrollView.bounces = NO;
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.viewController.automaticallyAdjustsScrollViewInsets = NO;
    }
    UIView *topView=[UIView new];
    [_scrollView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.top.mas_equalTo(NAV_HEIGHT+10);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(315);
    }];
    topView.layer.cornerRadius=4;
    topView.backgroundColor=[UIColor whiteColor];
    [self creatTopView:topView];
    
    UIView *bottomView=[UIView new];
    [_scrollView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(10);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(600);
    }];
    bottomView.layer.cornerRadius=4;
    bottomView.backgroundColor=[UIColor whiteColor];
    [self creatBottomView:bottomView];
    
    UIView *jianJieView=[UIView new];
    [_scrollView addSubview:jianJieView];
    [jianJieView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.top.mas_equalTo(bottomView.mas_bottom).mas_equalTo(10);
        make.width.mas_equalTo(_mainW-10);
        make.height.mas_equalTo(60);
    }];
    jianJieView.layer.cornerRadius=4;
    jianJieView.backgroundColor=[UIColor whiteColor];
    jianJieView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToJianJie:)];
    [jianJieView addGestureRecognizer:tapGesture2];
    
    UILabel *imageLabel=[UILabel new];
    [jianJieView addSubview:imageLabel];
    [imageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    imageLabel.text=@"个人简介";
    imageLabel.font=[UIFont systemFontOfSize:17];
    imageLabel.textColor=ColorWithRGB(49, 49, 49);
    
    
    UIImageView *jianTou=[UIImageView new];
    [jianJieView addSubview:jianTou];
    [jianTou mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(30);
    }];
    jianTou.image=[UIImage imageNamed:@"iconfont-fanhui-拷贝-3"];
    
    UIButton *btn=[UIButton new];
    [_scrollView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.width.mas_equalTo(_mainW-40);
        make.top.mas_equalTo(jianJieView.mas_bottom).mas_equalTo(50);
        make.height.mas_equalTo(50);
    }];
    btn.layer.cornerRadius=10;
    btn.backgroundColor=_backgroundColor;
    [btn setTitle:@"提交" forState:0];
    [btn setTitleColor:[UIColor whiteColor] forState:0];
    [btn addTarget:self action:@selector(tiJiao:) forControlEvents:UIControlEventTouchUpInside];
    
    _scrollView.contentSize = CGSizeMake(0, 1230);
    
}
-(void)creatTopView:(UIView *)topView{
    UIView *imageView=[UIView new];
    [topView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(60);
    }];
    
    UILabel *imageLabel=[UILabel new];
    [imageView addSubview:imageLabel];
    [imageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    imageLabel.text=@"头像";
    imageLabel.font=[UIFont systemFontOfSize:17];
    imageLabel.textColor=ColorWithRGB(49, 49, 49);
    
    
    _userImage=[UIImageView new];
    [imageView addSubview:_userImage];
    [_userImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.height.mas_equalTo(45);
    }];
    _userImage.layer.masksToBounds=YES;
    _userImage.layer.cornerRadius=45/2;
    NSString *wl_practice_photo=[_dic objectForKey:@"waiter_icon"];
    if ([ZQTools charIsNil:wl_practice_photo]) {
        _userImage.image=[UIImage imageNamed:@"未登录头像"];
    }
    else
    {
        wl_practice_photo=[NSString stringWithFormat:@"%@%@",_addressUrl,wl_practice_photo];
        NSURL *url=[NSURL URLWithString:wl_practice_photo];
        [_userImage sd_setImageWithURL:url];
    }
    _userImage.tag=1;
    _userImage.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(userIconChange:)];
    [_userImage addGestureRecognizer:tapGesture];
    
    UIView *xianView=[UIView new];
    [topView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(imageView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    
    UIView *nameView=[UIView new];
    [topView addSubview:nameView];
    [nameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView.mas_bottom);
    }];
    
    UILabel *nameLabel=[UILabel new];
    [nameView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    nameLabel.text=@"姓名";
    nameLabel.font=[UIFont systemFontOfSize:17];
    nameLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _nameText=[UITextField new];
    [nameView addSubview:_nameText];
    [_nameText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(150);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(35);
        make.right.mas_equalTo(-10);
    }];
    NSString *user_nickname=[_dic objectForKey:@"waiter_name"];
    if ([ZQTools charIsNil:user_nickname]) {
        _nameText.placeholder=@"请输入真实姓名";
    }else{
        _nameText.text=user_nickname;
    }
   
    _nameText.textColor=ColorWithRGB(49, 49, 49);
    _nameText.textAlignment=NSTextAlignmentRight;
    _nameText.delegate=self;
    _nameText.returnKeyType=UIReturnKeyDone;
    [_nameText addTarget:self action:@selector(onEditing:) forControlEvents:UIControlEventEditingDidEnd];
    
    
    UIView *xianView2=[UIView new];
    [topView addSubview:xianView2];
    [xianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(nameView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView2.backgroundColor=_LightGrey;
    
    UIView *sexView=[UIView new];
    [topView addSubview:sexView];
    [sexView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView2.mas_bottom);
    }];
    
    UILabel *sexLabel3=[UILabel new];
    [sexView addSubview:sexLabel3];
    [sexLabel3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    sexLabel3.text=@"性别";
    sexLabel3.textColor=ColorWithRGB(29, 29, 29);
    sexLabel3.font=[UIFont systemFontOfSize:17];
    
    UILabel *sexLabel=[UILabel new];
    [sexView addSubview:sexLabel];
    [sexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(20);
    }];
    sexLabel.text=@"女";
    sexLabel.font=[UIFont systemFontOfSize:16];
    sexLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _sexIamge1=[UIImageView new];
    [sexView addSubview:_sexIamge1];
    [_sexIamge1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(sexLabel.mas_left).mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.height.mas_equalTo(25);
    }];
    _sexIamge1.tag=0;
    _sexIamge1.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectSex:)];
    [_sexIamge1 addGestureRecognizer:tapGesture2];
    
    UILabel *sexLabel2=[UILabel new];
    [sexView addSubview:sexLabel2];
    [sexLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(_sexIamge1.mas_left).mas_equalTo(-20);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(20);
    }];
    sexLabel2.text=@"男";
    sexLabel2.font=[UIFont systemFontOfSize:16];
    sexLabel2.textColor=ColorWithRGB(49, 49, 49);
    
    
    _sexIamge2=[UIImageView new];
    [sexView addSubview:_sexIamge2];
    [_sexIamge2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(sexLabel2.mas_left).mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.height.mas_equalTo(25);
    }];
    _sexIamge2.userInteractionEnabled=YES;
    _sexIamge2.tag=1;
    UITapGestureRecognizer *tapGestur3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectSex:)];
    [_sexIamge2 addGestureRecognizer:tapGestur3];
    
    _sex=[[_dic objectForKey:@"waiter_sex"] intValue];
    if (_sex==0||_sex==2) {
        _sexIamge1.image=[UIImage imageNamed:@"是"];
        _sexIamge2.image=[UIImage imageNamed:@"否"];
    }
    else{
        _sexIamge2.image=[UIImage imageNamed:@"是"];
        _sexIamge1.image=[UIImage imageNamed:@"否"];
    }
    
    UIView *xianView3=[UIView new];
    [topView addSubview:xianView3];
    [xianView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(sexView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView3.backgroundColor=_LightGrey;
    
    UIView *ageView=[UIView new];
    [topView addSubview:ageView];
    [ageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView3.mas_bottom);
    }];
    
    UILabel *ageLabel=[UILabel new];
    [ageView addSubview:ageLabel];
    [ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    ageLabel.text=@"年龄";
    ageLabel.textColor=ColorWithRGB(29, 29, 29);
    ageLabel.font=[UIFont systemFontOfSize:17];
    
    _ageText=[UITextField new];
    [ageView addSubview:_ageText];
    [_ageText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(_nameText);
        make.centerY.mas_equalTo(0);
    }];
    NSNumber *waiter_age=[_dic objectForKey:@"waiter_age"];
    if ([waiter_age isKindOfClass:[NSNull class]]) {
        _ageText.placeholder=@"请输入真实年龄";
    }else{
        _ageText.text=[NSString stringWithFormat: @"%@",waiter_age];
    }
    _ageText.textColor=ColorWithRGB(49, 49, 49);
    _ageText.textAlignment=NSTextAlignmentRight;
    _ageText.delegate=self;
    _ageText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView4=[UIView new];
    [topView addSubview:xianView4];
    [xianView4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(ageView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView4.backgroundColor=_LightGrey;
    
    
    UIView *jiguanView=[UIView new];
    [topView addSubview:jiguanView];
    [jiguanView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView4.mas_bottom);
    }];
    
    UILabel *jiGuanLabel=[UILabel new];
    [jiguanView addSubview:jiGuanLabel];
    [jiGuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    jiGuanLabel.text=@"籍贯";
    jiGuanLabel.textColor=ColorWithRGB(29, 29, 29);
    jiGuanLabel.font=[UIFont systemFontOfSize:17];
    
    _addText=[UITextField new];
    [jiguanView addSubview:_addText];
    [_addText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(_nameText);
        make.centerY.mas_equalTo(0);
    }];
    NSString *waiter_place=[_dic objectForKey:@"waiter_place"];
    if ([ZQTools charIsNil:waiter_place]) {
        _addText.placeholder=@"请输所在籍贯";
    }else{
        _addText.text=waiter_place;
    }
    _addText.textColor=ColorWithRGB(49, 49, 49);
    _addText.textAlignment=NSTextAlignmentRight;
    _addText.delegate=self;
    _addText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView5=[UIView new];
    [topView addSubview:xianView5];
    [xianView5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(jiguanView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView5.backgroundColor=_LightGrey;
    
    
    UIView *diQuView=[UIView new];
    [topView addSubview:diQuView];
    [diQuView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView5.mas_bottom);
    }];
    
    UILabel *diquLabel=[UILabel new];
    [diQuView addSubview:diquLabel];
    [diquLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    diquLabel.text=@"地区";
    diquLabel.textColor=ColorWithRGB(29, 29, 29);
    diquLabel.font=[UIFont systemFontOfSize:17];
    
    UIImageView *jianTou=[UIImageView new];
    [diQuView addSubview:jianTou];
    [jianTou mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(15);
    }];
    jianTou.image=[UIImage imageNamed:@"iconfont-fanhui-拷贝-3"];
    
    _addLabel=[UILabel new];
    [diQuView addSubview:_addLabel];
    [_addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(jianTou.mas_left).mas_equalTo(-5);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(150);
    }];
    NSString *wl_city_name=[_dic objectForKey:@"wl_city_name"];
    NSString *wl_province_name=[_dic objectForKey:@"wl_province_name"];
    if ([ZQTools charIsNil:wl_city_name]) {
        _addLabel.text=@"请选择";
    }else{
        _addLabel.text=[NSString stringWithFormat:@"%@ %@",wl_province_name,wl_city_name];
    }
    _addLabel.textColor=ColorWithRGB(49, 49, 49);
    _addLabel.font=[UIFont systemFontOfSize:17];
    _addLabel.textAlignment=NSTextAlignmentRight;
    diQuView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGestur13 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectAdd:)];
    [diQuView addGestureRecognizer:tapGestur13];
    
}
-(void)creatBottomView:(UIView *)topView{
    UIView *zhuanChangView=[UIView new];
    [topView addSubview:zhuanChangView];
    [zhuanChangView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
    }];
    
    UILabel *ZhangChgangLabel=[UILabel new];
    [zhuanChangView addSubview:ZhangChgangLabel];
    [ZhangChgangLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    ZhangChgangLabel.text=@"专长类型";
    ZhangChgangLabel.font=[UIFont systemFontOfSize:17];
    ZhangChgangLabel.textColor=ColorWithRGB(49, 49, 49);
    
    UIImageView *jianTou=[UIImageView new];
    [zhuanChangView addSubview:jianTou];
    [jianTou mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(15);
    }];
    jianTou.image=[UIImage imageNamed:@"iconfont-fanhui-拷贝-3"];
    
    _ZCLabel=[UILabel new];
    [zhuanChangView addSubview:_ZCLabel];
    [_ZCLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(jianTou.mas_left).mas_equalTo(-5);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(150);
    }];
    NSString *wl_city_name=[_dic objectForKey:@"wl_field_names"];
    if ([ZQTools charIsNil:wl_city_name]) {
        _ZCLabel.text=@"请选择";
    }else{
        _ZCLabel.text=wl_city_name;
    }
    _ZCLabel.textColor=ColorWithRGB(49, 49, 49);
    _ZCLabel.font=[UIFont systemFontOfSize:17];
    _ZCLabel.textAlignment=NSTextAlignmentRight;
    
    zhuanChangView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGestur13 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectZC:)];
    [zhuanChangView addGestureRecognizer:tapGestur13];
    
    UIView *xianView=[UIView new];
    [topView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(zhuanChangView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    
    
    UIView *LSView=[UIView new];
    [topView addSubview:LSView];
    [LSView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView.mas_bottom);
    }];
    
    UILabel *LSLabel=[UILabel new];
    [LSView addSubview:LSLabel];
    [LSLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    LSLabel.text=@"律所";
    LSLabel.font=[UIFont systemFontOfSize:17];
    LSLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _GSText=[UITextField new];
    [LSView addSubview:_GSText];
    [_GSText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(_nameText);
        make.centerY.mas_equalTo(0);
    }];
    NSString *wl_firm=[_dic objectForKey:@"wl_firm"];
    if ([ZQTools charIsNil:wl_firm]) {
        _GSText.placeholder=@"请输入所在律所全名";
    }else{
        _GSText.text=wl_firm;
    }
    _GSText.textColor=ColorWithRGB(49, 49, 49);
    _GSText.textAlignment=NSTextAlignmentRight;
    _GSText.delegate=self;
    _GSText.returnKeyType=UIReturnKeyDone;
    
    
    UIView *xianView2=[UIView new];
    [topView addSubview:xianView2];
    [xianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(LSView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView2.backgroundColor=_LightGrey;
    
    
    UIView *ZZView=[UIView new];
    [topView addSubview:ZZView];
    [ZZView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView2.mas_bottom);
    }];
    
    UILabel *ZZLabel=[UILabel new];
    [ZZView addSubview:ZZLabel];
    [ZZLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    ZZLabel.text=@"执业证号";
    ZZLabel.font=[UIFont systemFontOfSize:17];
    ZZLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _ZYText=[UITextField new];
    [ZZView addSubview:_ZYText];
    [_ZYText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(_nameText);
        make.centerY.mas_equalTo(0);
    }];
    NSString *wl_practice=[_dic objectForKey:@"wl_practice"];
    if ([ZQTools charIsNil:wl_practice]) {
        _ZYText.placeholder=@"请输入执业证号";
    }else{
        _ZYText.text=[NSString stringWithFormat:@"%@",wl_practice];
    }
    _ZYText.textColor=ColorWithRGB(49, 49, 49);
    _ZYText.textAlignment=NSTextAlignmentRight;
    _ZYText.delegate=self;
    _ZYText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView3=[UIView new];
    [topView addSubview:xianView3];
    [xianView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(ZZView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView3.backgroundColor=_LightGrey;
    
    
    UIView *ZNView=[UIView new];
    [topView addSubview:ZNView];
    [ZNView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView3.mas_bottom);
    }];
    
    UILabel *ZNLabel=[UILabel new];
    [ZNView addSubview:ZNLabel];
    [ZNLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    ZNLabel.text=@"执业年限";
    ZNLabel.font=[UIFont systemFontOfSize:17];
    ZNLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _NXText=[UITextField new];
    [ZNView addSubview:_NXText];
    [_NXText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(_nameText);
        make.centerY.mas_equalTo(0);
    }];
    NSNumber *wl_length=[_dic objectForKey:@"wl_length"];
    if ([wl_practice isKindOfClass:[NSNull class]]) {
        _NXText.placeholder=@"请输入执业年限";
    }else{
        _NXText.text=[NSString stringWithFormat:@"%@",wl_length];
    }
    _NXText.textColor=ColorWithRGB(49, 49, 49);
    _NXText.textAlignment=NSTextAlignmentRight;
    _NXText.delegate=self;
    _NXText.returnKeyType=UIReturnKeyDone;
    
    
    UIView *xianView4=[UIView new];
    [topView addSubview:xianView4];
    [xianView4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(ZNView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView4.backgroundColor=_LightGrey;
    
    
    UIView *SZView=[UIView new];
    [topView addSubview:SZView];
    [SZView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView4.mas_bottom);
    }];
    
    UILabel *SZLabel=[UILabel new];
    [SZView addSubview:SZLabel];
    [SZLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    SZLabel.text=@"身份证号";
    SZLabel.font=[UIFont systemFontOfSize:17];
    SZLabel.textColor=ColorWithRGB(49, 49, 49);
    
    _NumText=[UITextField new];
    [SZView addSubview:_NumText];
    [_NumText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.left.right.mas_equalTo(_nameText);
        make.centerY.mas_equalTo(0);
    }];
    NSString *waiter_carded=[_dic objectForKey:@"waiter_carded"];
    if ([ZQTools charIsNil:waiter_carded]) {
        _NumText.placeholder=@"请输入身份证号码";
    }else{
        _NumText.text=waiter_carded;
    }
    _NumText.textColor=ColorWithRGB(49, 49, 49);
    _NumText.textAlignment=NSTextAlignmentRight;
    _NumText.delegate=self;
    _NumText.returnKeyType=UIReturnKeyDone;
    
    UIView *xianView5=[UIView new];
    [topView addSubview:xianView5];
    [xianView5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(SZView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView5.backgroundColor=_LightGrey;
    
    UIView *SCZView=[UIView new];
    [topView addSubview:SCZView];
    [SCZView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(xianView5.mas_bottom);
    }];
    
    UILabel *SCZLabel=[UILabel new];
    [SCZView addSubview:SCZLabel];
    [SCZLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    SCZLabel.text=@"上传证件照片";
    SCZLabel.font=[UIFont systemFontOfSize:17];
    SCZLabel.textColor=ColorWithRGB(49, 49, 49);
    
    NSString *wl_practice_photo=[_dic objectForKey:@"wl_practice_photo"];
    
    _ZYImage=[UIImageView new];
    [topView addSubview:_ZYImage];
    [_ZYImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(40);
        make.height.width.mas_equalTo(100);
        make.top.mas_equalTo(SCZView.mas_bottom);
    }];
    if ([ZQTools charIsNil:wl_practice_photo]) {
        _ZYNum=1;
        _ZYImage.image=[UIImage imageNamed:@"上传"];
    }
    else
    {
        _ZYNum=2;
        wl_practice_photo=[NSString stringWithFormat:@"%@%@",_addressUrl,wl_practice_photo];
        NSURL *url=[NSURL URLWithString:wl_practice_photo];
        [_ZYImage sd_setImageWithURL:url];
    }
    _ZYImage.tag=2;
    _ZYImage.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(userIconChange:)];
    [_ZYImage addGestureRecognizer:tapGesture];
    
    NSString *wl_practice_auditors=[_dic objectForKey:@"wl_practice_auditors"];
    _NJIImage=[UIImageView new];
    [topView addSubview:_NJIImage];
    [_NJIImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-40);
        make.height.width.mas_equalTo(100);
        make.top.mas_equalTo(SCZView.mas_bottom);
    }];
    if ([ZQTools charIsNil:wl_practice_auditors]) {
        _NJNum=1;
        _NJIImage.image=[UIImage imageNamed:@"上传"];
    }
    else
    {
        _NJNum=2;
        wl_practice_auditors=[NSString stringWithFormat:@"%@%@",_addressUrl,wl_practice_auditors];
        NSURL *url=[NSURL URLWithString:wl_practice_auditors];
        [_NJIImage sd_setImageWithURL:url];
    }
    _NJIImage.tag=3;
    _NJIImage.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(userIconChange:)];
    [_NJIImage addGestureRecognizer:tapGesture2];
    
    
    UIImageView *iamgeView=[UIImageView new];
    [topView addSubview:iamgeView];
    [iamgeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.width.height.mas_equalTo(_ZYImage);
        make.top.mas_equalTo(_ZYImage.mas_bottom).mas_equalTo(20);
    }];
    iamgeView.image=[UIImage imageNamed:@""];
    iamgeView.layer.cornerRadius=3;
    iamgeView.backgroundColor=_tianLanColor;
    
    UILabel *label2=[UILabel new];
    [topView addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(iamgeView);
        make.top.mas_equalTo(iamgeView.mas_bottom).mas_equalTo(10);
    }];
    label2.text=@"执业证内页示例";
    label2.textColor=_backgroundColor;
    label2.font=[UIFont systemFontOfSize:16];
    
    
    UIImageView *iamgeView2=[UIImageView new];
    [topView addSubview:iamgeView2];
    [iamgeView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.width.height.mas_equalTo(_NJIImage);
        make.top.mas_equalTo(_ZYImage.mas_bottom).mas_equalTo(20);
    }];
    iamgeView2.image=[UIImage imageNamed:@""];
    iamgeView2.layer.cornerRadius=3;
    iamgeView2.backgroundColor=_tianLanColor;
    
    UILabel *label3=[UILabel new];
    [topView addSubview:label3];
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(iamgeView2);
        make.top.mas_equalTo(iamgeView.mas_bottom).mas_equalTo(10);
    }];
    label3.text=@"执业证年检示例";
    label3.textColor=_backgroundColor;
    label3.font=[UIFont systemFontOfSize:16];
}

-(void)selectZC:(UITapGestureRecognizer *)tap{
    [_addText resignFirstResponder];
    [_ageText resignFirstResponder];
    [_nameText resignFirstResponder];
    [_GSText resignFirstResponder];
    [_ZYText resignFirstResponder];
    [_NXText resignFirstResponder];
    [_NumText resignFirstResponder];
    
    NSDictionary *dic2=[NSDictionary dictionaryWithObjectsAndKeys:@"0",@"ct_id", nil];
    [ZQTools AFNPostDataUrl:@"api/index/case_type" Dict:dic2 andTableView:nil  andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        selectZC *lawView=[selectZC new];
        [self addSubview:lawView];
        [lawView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.mas_equalTo(0);
        }];
        lawView.shengArr=responseObject;
        [lawView creatView];
        lawView.customSelectedBlock2 = ^ (NSArray *arr)
        {
            _selectZC=arr;
            NSString *mergename=@"";
            for (int i=0; i<arr.count; i++) {
                NSDictionary *dic=arr[i];
                mergename=[NSString stringWithFormat:@"%@,%@",mergename,[dic objectForKey:@"ct_name"]];
            }
            if (![ZQTools charIsNil:mergename]) {
                mergename=[mergename substringFromIndex:1];
                _ZCLabel.text=mergename;
            }
        };
        
    } anderrorBlock:nil];
}
-(void)selectAdd:(UITapGestureRecognizer *)tap{
    [_addText resignFirstResponder];
    [_ageText resignFirstResponder];
    [_nameText resignFirstResponder];
    [_GSText resignFirstResponder];
    [_ZYText resignFirstResponder];
    [_NXText resignFirstResponder];
    [_NumText resignFirstResponder];
    
    NSDictionary *dic2=[NSDictionary dictionaryWithObjectsAndKeys:@"0",@"id", nil];
    [ZQTools AFNPostDataUrl:@"api/index/area_list" Dict:dic2 andTableView:nil  andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        selectAddView *lawView=[selectAddView new];
        [self addSubview:lawView];
        [lawView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.mas_equalTo(0);
        }];
        lawView.shengArr=responseObject;
        [lawView creatView];
        lawView.customSelectedBlock = ^ (NSDictionary *dic)
        {
            _selectAddDic=dic;
            NSString *mergename=[dic objectForKey:@"mergename"];
            NSArray *arr=[mergename componentsSeparatedByString:@","];
            NSString *Str=@"";
            for (int i=0; i<arr.count; i++) {
                Str=[NSString stringWithFormat:@"%@ %@",Str,arr[i]];
            }
            _addLabel.text=Str;
        };
        
    } anderrorBlock:nil];
}

-(void)selectSex:(UITapGestureRecognizer *)tap{
    
    [_addText resignFirstResponder];
    [_ageText resignFirstResponder];
    [_nameText resignFirstResponder];
    [_GSText resignFirstResponder];
    [_ZYText resignFirstResponder];
    [_NXText resignFirstResponder];
    [_NumText resignFirstResponder];
    
    _sex=(int)tap.view.tag;
    if (_sex==0||_sex==2) {
        _sexIamge1.image=[UIImage imageNamed:@"是"];
        _sexIamge2.image=[UIImage imageNamed:@"否"];
    }
    else{
        _sexIamge1.image=[UIImage imageNamed:@"否"];
        _sexIamge2.image=[UIImage imageNamed:@"是"];
        
    }
}
-(void) pushToJianJie:(UITapGestureRecognizer *)tap{
    jianJieViewController *jianjie=[[jianJieViewController alloc] init];
    jianjie.dic=self.dic;
    [ZQTools pushNextViewController:self.viewController andRootController:jianjie];
}

-(void) userIconChange:(UITapGestureRecognizer *)tap{
    
    
    [_addText resignFirstResponder];
    [_ageText resignFirstResponder];
    [_nameText resignFirstResponder];
    [_GSText resignFirstResponder];
    [_ZYText resignFirstResponder];
    [_NXText resignFirstResponder];
    [_NumText resignFirstResponder];
    
    if (tap.view.tag==1) {
        _imgNum=@1;
    }if (tap.view.tag==2) {
        _imgNum=@2;
    }if (tap.view.tag==3) {
        _imgNum=@3;
    }
    
  
    
    UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle: @"" message: @"拍照或从相册中选择" preferredStyle: UIAlertControllerStyleActionSheet];
    
    [actionSheetController addAction: [UIAlertAction actionWithTitle:@"打开相册"style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        
        [self LocalPhoto];
        
    }]];
    [actionSheetController addAction: [UIAlertAction actionWithTitle: @"拍照" style: UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
        [self locaXiangJi];
        
        
    }]];
    
    [actionSheetController addAction: [UIAlertAction actionWithTitle:@"取消"style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action) {}]];
    
    [self.viewController presentViewController: actionSheetController animated:YES completion:^{}];
    
}
-(IBAction)tiJiao:(id)sender{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"waiter_id"];
    NSString *waiter_id=[NSString stringWithFormat:@"%@",waiter_id1];
    
    NSString *waiter_name=_nameText.text;
    NSString *waiter_sex=[NSString stringWithFormat:@"%d",_sex];
    NSString *waiter_age=_ageText.text;
    NSString *waiter_place=_addText.text;
    
    NSNumber *wl_city_id2=[_selectAddDic objectForKey:@"id"];
    NSString *wl_city_id=[NSString stringWithFormat:@"%@",wl_city_id2];
    
    NSNumber *wl_province_id2=[_selectAddDic objectForKey:@"pid"];
    NSString *wl_province_id=[NSString stringWithFormat:@"%@",wl_province_id2];
    
    
    NSMutableArray *wl_field_ids=[NSMutableArray arrayWithCapacity:0];
    if (_selectZC.count!=0) {
        for (int i=0; i<_selectZC.count; i++) {
            NSDictionary *dict=_selectZC[i];
            NSNumber *ct_id2=[dict objectForKey:@"ct_id"];
            [wl_field_ids addObject:[NSString stringWithFormat:@"%@",ct_id2]];
        }

        
    }
    
    NSString *wl_firm=_GSText.text;
    NSString *wl_length=_NXText.text;
    NSString *waiter_carded=_NumText.text;
    NSString *wl_practice=_ZYText.text;
    NSMutableDictionary *typeDic=[NSMutableDictionary dictionaryWithCapacity:0];
    [typeDic setObject:waiter_id forKey:@"waiter_id"];
    [typeDic setObject:token forKey:@"token"];
    [typeDic setObject:@"1" forKey:@"user_role"];
    [typeDic setObject:waiter_name forKey:@"waiter_name"];
    [typeDic setObject:waiter_sex forKey:@"waiter_sex"];
    [typeDic setObject:waiter_age forKey:@"waiter_age"];
    [typeDic setObject:waiter_place forKey:@"waiter_place"];
    if (_selectAddDic!=nil) {
        [typeDic setObject:wl_city_id forKey:@"wl_city_id"];
        [typeDic setObject:wl_province_id forKeyedSubscript:@"wl_province_id"];
    }
    
    [typeDic setObject:wl_firm forKey:@"wl_firm"];
    [typeDic setObject:wl_length forKey:@"wl_length"];
    [typeDic setObject:waiter_carded forKey:@"waiter_carded"];
    [typeDic setObject:wl_practice forKey:@"wl_practice"];
    if (wl_field_ids.count!=0) {
         [typeDic setObject:wl_field_ids forKey:@"wl_field_ids"];
    }
    
    if (_selectZC.count!=0) {
     
        NSDictionary *dict=_selectZC[0];
        NSNumber *ct_pid2=[dict objectForKey:@"ct_pid"];
         [typeDic setObject:[NSString stringWithFormat:@"%@",ct_pid2] forKey:@"wl_type_ids"];
    }
    
    
    NSMutableArray *imageArr=[NSMutableArray arrayWithCapacity:0];
    
    UIImage *usrImge=_userImage.image;
    NSDictionary *dic2=[NSDictionary dictionaryWithObjectsAndKeys:usrImge,@"image",@"waiter_icon",@"fileName", nil];
    [imageArr addObject:dic2];
    if (_ZYNum==2) {
        UIImage *usrImge2=_ZYImage.image;
        NSDictionary *dic3=[NSDictionary dictionaryWithObjectsAndKeys:usrImge2,@"image",@"wl_practice_photo",@"fileName", nil];
        [imageArr addObject:dic3];
    }
    if (_NJNum==2) {
        UIImage *usrImge2=_NJIImage.image;
        NSDictionary *dic3=[NSDictionary dictionaryWithObjectsAndKeys:usrImge2,@"image",@"wl_practice_auditors",@"fileName", nil];
        [imageArr addObject:dic3];
    }
    
    [ZQTools afnPostImageWithDict:typeDic WithAddressUrl:@"waiter/waiter/update_lawyer" withImageArr:imageArr withFileName:nil fileOrImg:@"image" WithViewController:self.viewController success:^(id responseObject) {
        [ZQTools svpInfo:@"修改成功"];
        [self.viewController.navigationController popViewControllerAnimated:YES];
    }];
    
}

-(void)locaXiangJi{
 
    
    UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
    
    UIImagePickerControllerQualityType qualityType = UIImagePickerControllerQualityTypeHigh;
    
    /*判断是否有相机*/
    
    if([UIImagePickerController isSourceTypeAvailable : UIImagePickerControllerSourceTypeCamera]){
        
        UIImagePickerController *picker = [[UIImagePickerController alloc]init];
        
        picker.delegate=self;
        
        /*设置拍照后的图片可被编辑*/
        
        picker.allowsEditing=YES;
        
        /*资源类型为照相机*/
        
        picker.sourceType= sourceType;
        
        /*品质为高*/
        
        picker.videoQuality= qualityType;
        
        [self.viewController presentViewController: picker animated:YES completion:^{
            
            
        }];
        
    }else{
        //        [self alertTitle:@"该设备无摄像头"];
        
    }
    
}
-(void)LocalPhoto
{
    
    UIImagePickerController *picker = [[UIImagePickerController alloc]init];
    
    /*资源类型为图片库*/
    
    picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
    
    picker.delegate=self;
    
    /*设置选择后的图片可被编辑*/
    
    picker.allowsEditing=YES;
    
    [self.viewController presentViewController:picker animated:YES completion:^{
        
        
    }];
    
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    
    
    [picker dismissViewControllerAnimated:YES completion:^{
        
        UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
        if (_imgNum.intValue==1) {
            _userImage.image=image;
        }if (_imgNum.intValue==2) {
            _ZYNum=2;
            _ZYImage.image=image;
        }if (_imgNum.intValue==3) {
            _NJNum=2;
            _NJIImage.image=image;
        }
        
        
        
    }];
    
}

-(void)onEditing:(UITextField *)textField{
    if (textField.text.length > 20)
    {
        [ZQTools svpInfo:@"姓名不能超过20个字"];
        textField.text=[textField.text substringToIndex:15];
    }
    
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string{
    if ([[[UITextInputMode currentInputMode]primaryLanguage] isEqualToString:@"emoji"]) {
        return NO;
    }
    return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{

    
    [textField resignFirstResponder];
    return YES;
}
@end
